<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let a = 1;
      let b = "bb";
      let obj = {
        name: "obj",
        age: 12,
        list: ["obj"],
      };

      let c = a;
      c = 2;

      const oldlist = [{ name: "pp" }];
      let newList = [...oldlist];
      newList = ["new"];
      console.log(oldlist, newList);
      // console.log(c, a); // a c 互不打扰p
      // let ib = obj;
      // ib.name = "ib";
      // console.log(obj, ib, ib === obj); //ib === info
      //es 自带浅拷贝
      // const newObj = Object.assign({}, obj);
      const newObj = { ...obj };

      newObj.name = "newObj";
      newObj.list = ["newObj"];
      console.log(newObj, obj);
      // 可以发现简单数据类型是实现了拷贝 新的和原来的不一样 修改新的不会影响原有的
    </script>
  </body>
</html>
